package netWork;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 86186
 * Date: 2023-10-17
 * Time: 17:42
 */
public class TcpDictServer extends TcpEchoServer{
    Map<String, String> dict = new HashMap<>();
    public TcpDictServer(int port) throws IOException {
        super(port);
        dict.put("cat","猫");
        dict.put("dog","狗");
        dict.put("pig","猪");
        dict.put("bird","鸟");
    }

    @Override
    public String process(String request) {
        return dict.getOrDefault(request,"您查找的单词在该词典中不存在");
    }

    public static void main(String[] args) throws IOException {
        TcpDictServer tcpDictServer = new TcpDictServer(9905);
        tcpDictServer.run();
    }
}
